home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright (C) 1994, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
- #include <stdlib.h>
- #include "InventorSplineClass.h"
-
-
- InvSplineClass::InvSplineClass(SoMFVec4f *all)
- {
- double *t, *tx, *ty, *tz;
- int n = all->getNum();
- const SoMFVec4f &allto = (*all);
-
- t = (double *) malloc(n * sizeof(double));
- tx = (double *) malloc(n * sizeof(double));
- ty = (double *) malloc(n * sizeof(double));
- tz = (double *) malloc(n * sizeof(double));
-
- float tval, xval, yval, zval;
- SbVec4f blah;
- for (int i = 0; i < n; i++) {
- blah = (allto[i]);
- blah.getValue(tval, xval, yval, zval);
- t[i] = (double) tval;
- tx[i] = (double) xval;
- ty[i] = (double) yval;
- tz[i] = (double) zval;
- }
- x = new SplineClass(n, t, tx);
- y = new SplineClass(n, t, ty);
- z = new SplineClass(n, t, tz);
-
- free(t);
- free(tx);
- free(ty);
- free(tz);
- }
-
- InvSplineClass::InvSplineClass(SoMFVec2f *tax, SoMFVec2f *tay, SoMFVec2f *taz)
- {
- double *tx, *ty, *tz, *ttx, *tty, *ttz;
- int nx = tax->getNum();
- int ny = tay->getNum();
- int nz = taz->getNum();
- const SoMFVec2f &ttax = (*tax);
- const SoMFVec2f &ttay = (*tay);
- const SoMFVec2f &ttaz = (*taz);
-
- tx = (double *) malloc(nx * sizeof(double));
- ty = (double *) malloc(ny * sizeof(double));
- tz = (double *) malloc(nz * sizeof(double));
- ttx = (double *) malloc(nx * sizeof(double));
- tty = (double *) malloc(ny * sizeof(double));
- ttz = (double *) malloc(nz * sizeof(double));
-
-
- float xval, yval, zval, txval, tyval, tzval;
- SbVec2f xvec, yvec, zvec;
- for (int i = 0; i < nx; i++) {
- xvec = ttax[i];
- xvec.getValue(txval, xval);
- tx[i] = (double) xval;
- ttx[i] = (double) txval;
- }
-
- for (i = 0; i < ny; i++) {
- yvec = ttay[i];
- yvec.getValue(tyval, yval);
- ty[i] = (double) yval;
- tty[i] = (double) tyval;
- }
-
- for (i = 0; i < nz; i++) {
- zvec = ttaz[i];
- zvec.getValue(tzval, zval);
- tz[i] = (double) zval;
- ttz[i] = (double) tzval;
- }
-
- x = new SplineClass(nx, ttx, tx);
- y = new SplineClass(ny, tty, ty);
- z = new SplineClass(nz, ttz, tz);
-
- free(tx);
- free(ty);
- free(tz);
- free(ttx);
- free(tty);
- free(ttz);
- }
-
-
- SbVec3f InvSplineClass::evaluate(double t) {
- SbVec3f result;
-
- result.setValue(x->evaluate(t), y->evaluate(t), z->evaluate(t));
- return result;
- }
-
- InvSplineClass::~InvSplineClass()
- {
- }
-